home *** CD-ROM | disk | FTP | other *** search
- ' GEM Shell
- ' by John Eidsvoog
- ' Saturday, August 29, 1992
- '
- ' This program show how windows can be correctly manipulated in GFA
- ' in the manner in which GEM was designed, rather than resorting to
- ' techniques such as "Use ACCs" options to avoid handling redraw messages
- ' correctly.
- '
- ' GEM Shell may be freely distributed, dissected, and any portion may be used
- ' in any way you deem necessary. Hopefully, it will inspire more programmers
- ' to follow the recommended rules of GEM programming.
- '
- @init
- ON MENU MESSAGE GOSUB message
- ON MENU GOSUB menuselect
- ON MENU KEY GOSUB mkey
- exit%=FALSE
- REPEAT
- ON MENU
- UNTIL exit%
- CLOSEW #1
- '
- > PROCEDURE init ! Initialize things
- DEFINT "a-z" ! Make 'em all integers
- DIM menu$(14)
- FOR x%=0 TO 14 ! Read in menubar strings
- READ menu$(x%)
- NEXT x%
- '
- DATA "Desk"," About GEM Shell ",--------------------,1,2,3,4,5,6,""
- DATA "File"," Quit ",""
- DATA "",""
- '
- GEMSYS 77 ! graf_handle
- xchar%=INT{GINTOUT+2} ! character width
- ychar%=INT{GINTOUT+4} ! character height
- '
- ~APPL_INIT()
- '
- MENU menu$()
- ~WIND_GET(0,4,wx%,wy%,ww%,wh%) ! Get work area of the desktop
- ~FORM_DIAL(3,0,0,0,0,wx%,wy%,ww%,wh%) ! Send a redraw message to the desktop
- wx%=ww%/2-xchar%*17-7 ! Set up a default window size and center it
- wy%=wh%/2-ychar%*6
- ww%=xchar%*34
- wh%=ychar%*14
- TITLEW #1," GEM Shell "
- INFOW #1,""
- OPENW #1,wx%,wy%,ww%,wh%,&X101111 ! Open our window
- handle%=W_HAND(#1)
- RETURN
- > PROCEDURE message ! Handle GEM messages
- wx%=MENU(5) ! intout coordinates
- wy%=MENU(6)
- ww%=MENU(7)
- wh%=MENU(8)
- '
- SELECT MENU(1) ! Get message type
- CASE 20 ! WM_REDRAW
- @redraw
- CASE 21 ! WM_TOPPED
- TOPW #1
- CASE 22 ! WM_CLOSED
- @quit
- CASE 23 ! WM_FULLED
- full%=1-full% ! Toggle between full and normal
- IF full%
- ox%=wx% ! If we're going to "full", save old window size
- oy%=wy%
- ow%=ww%
- oh%=wh%
- FULLW #1
- ELSE ! Otherwise set it back to old size
- ~WIND_SET(handle%,5,ox%,oy%,ow%,oh%)
- ENDIF
- CASE 27 ! WM_SIZED
- full%=0
- ~WIND_SET(handle%,5,wx%,wy%,MAX(180,ww%),MAX(80,wh%))
- CASE 28 ! WM_MOVED
- full%=0
- ~WIND_SET(handle%,5,wx%,wy%,ww%,wh%)
- ENDSELECT
- RETURN
- > PROCEDURE menuselect ! Handle menubar selections
- SELECT MENU(5)
- CASE 23
- @about ! Open the "About" alert box
- CASE 32
- @quit ! Bail out
- ENDSELECT
- MENU OFF
- RETURN
- > PROCEDURE mkey ! Handle keypresses
- k$=UPPER$(CHR$(MENU(14) AND 255))
- SELECT k$
- CASE " " ! Spacebar brings up About box
- @about
- CASE "Q",27 ! Q or Esc quits program
- @quit
- ENDSELECT
- RETURN
- > PROCEDURE about ! Tell 'em what we've got, Bob.
- ALERT 1," | GEM Shell | By John Eidsvoog ",1," OK ",b%
- RETURN
- > PROCEDURE redraw ! Walk the rectangle list and do redraws
- ~WIND_UPDATE(1) ! Lock out other activity while we redraw
- ~WIND_GET(handle%,11,rx%,ry%,rw%,rh%) ! Get first rectangle in the list
- ~WIND_GET(handle%,4,ax%,ay%,aw%,ah%) ! Work area of our window
- REPEAT
- IF RC_INTERSECT(ax%,ay%,aw%,ah%,rx%,ry%,rw%,rh%) ! Find intersection
- CLIP rx%,ry%,rw%,rh% OFFSET ax%,ay% ! Set clipping to the area in question
- CLEARW #1 ! Clear the area
- @fillwindow ! Call our routine to redraw the area
- CLIP 0,0,WORK_OUT(0),WORK_OUT(1) ! Reset full-screen clipping
- ENDIF
- ~WIND_GET(handle%,12,rx%,ry%,rw%,rh%) ! Get next rectangle in the list
- UNTIL rw%=0 AND rh%=0 ! Keep repeating until no more rectangles
- ~WIND_UPDATE(0) ! Reenable other GEM activity
- RETURN
- > PROCEDURE fillwindow ! Redraw sections of our window
- ' Replace this routine with whatever is needed to redraw your window.
- TEXT 8,ychar%," This is some sample text,"
- TEXT 8,2*ychar%," showing how redraws can"
- TEXT 8,3*ychar%," be handled correctly in"
- TEXT 8,4*ychar%," GFA while still following"
- TEXT 8,5*ychar%," GEM guidelines for multiple"
- TEXT 8,6*ychar%," windows. This window can"
- TEXT 8,7*ychar%," be resized, moved, or made"
- TEXT 8,8*ychar%," 'full', and windowed ACCs"
- TEXT 8,9*ychar%," made be opened and manipu-"
- TEXT 8,10*ychar%," lated without redraw"
- TEXT 8,11*ychar%," problems."
- RETURN
- > PROCEDURE quit
- ALERT 3," | Do you want to quit? | ",1," Quit | No ",b%
- IF b%=1
- CLOSEW #1
- ~APPL_EXIT()
- exit%=TRUE
- ENDIF
- RETURN
-